﻿using System;
using System.IO;
using YArchitech.LIB;

namespace YJKOpeningCommon.Public
{
	public class ExceptionLog
	{
		public static void WriteLog(string strMsg, bool isAppend)
		{
			if (ExceptionLog.m_file == null)
			{
				ExceptionLog.m_file = new StreamWriter(ExceptionLog.strFilePath, isAppend);
			}
			if (ExceptionLog.m_file == null)
			{
				return;
			}
			ExceptionLog.WriteException2Log(strMsg);
		}

		private static void WriteException2Log(string str)
		{
			string text = DateTime.Now.ToString() + " Exception：";
			text = text + str + "\r\n";
			ExceptionLog.m_file.WriteLine(text);
		}

		public static void CloseLogFile()
		{
			if (ExceptionLog.m_file != null)
			{
				ExceptionLog.m_file.Close();
				ExceptionLog.m_file = null;
			}
		}

		private static string strFilePath = Product.UserDataLocation + "\\CommandLog.txt";

		private static StreamWriter m_file = null;
	}
}
